import * as actionTypes from '../constants/index';
import {filterTabData} from  '../until'

const initState = {
    tableData:[],
    switchlist:[],
    isFirst:true,
    sortType:'desc',
    scope:-1,
    websiteType :-1,
    positiveOrNegative:-1,
    currentPage:1,
    limit:10,
    sortField:'poTime',
    abroad:-1,
    categoryId:'',
    searchType:"all",
    topicId:"",
    totals:0,
    choselist:[0,0,0,0,0,0,0],
    id:'',
    titleContentPrint:'',
    loading:true,
    updatewebsite:'',
    updomain:'',
    uptype:0 //0 加入 1 修改

    
}
const inforesult =(state =initState, action)=>{
  switch (action.type) {
    case actionTypes.GET_TAG_LIST:
      return { ...state, tableData:action.payload,totals:action.total}
    case actionTypes.NEGATIVE:
      // return {...state,positiveOrNegative:action.positiveOrNegative}
      return {...state,positiveOrNegative:action.positiveOrNegative,isFirst:action.isFirst}
      case actionTypes.SCOPE:
      // return {...state,positiveOrNegative:action.positiveOrNegative}
      return {...state,scope:action.scope,isFirst:action.isFirst}
      case actionTypes.ASDESC:
      // return {...state,positiveOrNegative:action.positiveOrNegative}
      return {...state,sortType:action.sortType,sortField:action.sortField,isFirst:action.isFirst}
      case actionTypes.CLEARAll:
      return {...state,positiveOrNegative:action.positiveOrNegative,sortType:action.sortType,sortField:action.sortField,isFirst:action.isFirst}
      case actionTypes.PAGESIZE:
      return{...state,limit:action.pagesize}
      case actionTypes.DELETE:
      return {...state,tableData:filterTabData(state.tableData,action.id)}
      case actionTypes.EXPORTSELECTS:
      return {...state,id:action.id}
      case actionTypes.WEBSITE:
      return {...state,websiteType:action.websiteType}
      case actionTypes.SWITCH:
      return {...state,switchlist:action.switchlist}
      case actionTypes.REMOVEACTION:
      return  {...state,choselist:action.choselist}
      case actionTypes.DETAIL:
      return  {...state,id:action.id,titleContentPrint:action.titleContentPrint}
      case actionTypes.LOADING:
      return  {...state,loading:action.loading}
      case actionTypes.UPDATE:
      return{...state,updatewebsite:action.updatewebsite,updomain:action.updomain,uptype:action.uptype}
    default:
      return state;
  }
}
export  { inforesult }


